package cc.chinagps.gateway.client.protocol.decoder;

import cc.chinagps.gateway.client.UnitClient;
import cc.chinagps.gateway.client.packet.BasePacket;
import cc.chinagps.gateway.client.protocol.Decoder;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public abstract class BaseDecoder implements Decoder {
    private UnitClient client;
    @Override
    public UnitClient getClient() {
        return client;
    }

    @Override
    public void setClient(UnitClient client) {
        this.client = client;
    }

    @Override
    public abstract void handlerPacket(BasePacket packet, byte[] data) throws Exception;

    @Override
    public void handlerPacket(BasePacket packet) throws Exception {
        handlerPacket(packet, packet.getMsgBody());
    }

    @Override
    public boolean preHandle(BasePacket packet) throws Exception {
        return true;
    }

    @Override
    public void postHandle(BasePacket packet) throws Exception {
    }
}
